var Ajax = function(option){
	/*option
	 * url
	 * params
	 * maskTarget
	 * window
	 * grid
	 * success
	 * */
	option.maskTarget.el.mask("正在操作 ...","x-mask-loading");
	Ext.Ajax.request({
		url : option.url,
		params : option.params,
		success : function(resp){
			var obj = Ext.decode(resp.responseText);
			notice_result_info(obj.info);
			option.maskTarget.el.unmask();
			if(obj.status){
				if(option.grid    != undefined) option.grid.store.reload();
				if(option.window  != undefined) option.window.hide();
				if(option.success != undefined) option.success();
			}
		},
		failure : function(){
			notice_result_info("网络错误");
		}
	});
}

var message_window = null;
var notice_result_info = function(info) {
	if (message_window) {
		message_window.hide();
	}
	message_window = new Ext.ux.window.MessageWindow({
		title : "操作结果",
		html : info || 'NO information available',
		origin : {
			offY : -5,
			offX : -5
		},
		width : 270,
		autoHeight : true,
		help : false,
		hideFx : {
			delay : 5000,
			mode : 'standard'
		}
	}).show(Ext.getDoc());
};

var object2Entity = function(json, name){
	var obj = {};
	for(var key in json){
		obj[name+"."+key] = json[key];
	}
	return obj;
}